package main

import (
	"io"
	"os"
	"yundata-service/router"

	"github.com/gin-gonic/gin"

	"yundata-service/internal/db"

	"yundata-service/internal"
)

func main() {
	// 初始化数据库连接
	var err error
	internal.GDb, err = db.Gorm() // gorm连接数据库
	if err != nil {
		panic(err)
	} else {
		db, _ := internal.GDb.DB()
		defer db.Close()
	}

	e := gin.New()
	f, _ := os.Create("./log/gin.log")
	gin.DefaultWriter = io.MultiWriter(f)

	// 初始化后台API路由
	router.InitApiRouter(e)

	e.Run(":10000")

}
